/*
 * Universidad del Valle de Guatemala
 * Departamento de Ciencias de la Computacion
 * Algoritmos y Estructuras de Datos
 * Hoja de Trabajo 5
 * David Coronado, 07325
 */

/**
 *
 * @author David Coronado
 */
import java.util.PriorityQueue;
import java.util.Comparator;

public class JFC_Implementation<E> implements Priority_Queue_Interface {

    PriorityQueue queue;

    /**
     * Constructor. Builds the comparator object and it's compare method.
     */
    public JFC_Implementation() {

        queue = new PriorityQueue(1000, new Comparator<E>() {

            public int compare(E num1, E num2) {

                int n1 = Integer.parseInt(num1 + "");
                int n2 = Integer.parseInt(num2 + "");

                if (n1 < n2) {
                    return 1;
                } else if (n1 > n2) {
                    return -1;
                } else {
                    return 0;
                }

            }
        });
    }

    /**
     *
     * @param number added to the queue
     */
    public void add(Object number) {
            queue.add(number);
    }

    /**
     *
     * @return the element with the highest priority
     */
    public E remove() {
        return (E) queue.remove();
    }

    /**
     *
     * @return true if the queue is empty, false if not.
     */
    public boolean isEmpty() {
        return queue.isEmpty();
    }


}
